DEFINITION MODULE ScreenHandler;

  (* Basic screen handling procedures.
     The active window is considered as the screen. *)

  CONST
    (* Screen attributes which can be used for any parameters requesting an
       attribute, such as ScrollUp *)

    (* Monochrome attributes *)
    Blank                  = 0;
    Normal                 = 7;
    Underlined             = 1;
    Bold                   = 15;
    Blink                  = 135;
    Reverse                = 112;
    BoldUnderlined         = 9;
    BoldBlinking           = 143;
    ReverseBlinking        = 240;
    UnderlinedBlinking     = 129;
    BoldUnderlinedBlinking = 137;

    (* Dark colours *)
    Black                  =  0;
    Blue                   =  1;
    Green                  =  2;
    Cyan                   =  3;
    Red                    =  4;
    Magenta                =  5;
    Brown                  =  6;
    LightGrey              =  7;

    (* Light colours *)
    DarkGrey     	   =  8;
    LightBlue    	   =  9;
    LightGreen   	   = 10;
    LightCyan    	   = 11;
    LightRed     	   = 12;
    LightMagenta	   = 13;
    Yellow       	   = 14;
    White        	   = 15;

(*****************************************************************************)
(*                                                                           *)
(*                            P R O C E D U R E S                            *)
(*                            -------------------                            *)
(*                                                                           *)
(*****************************************************************************)

  PROCEDURE CursorOn;

    (* This routine will re-display the cursor onto the screen *)

    (* 11 indicates the highest value of display of the cursor and 12 the
       lowest value of display for the cursor *)


  PROCEDURE CursorOff;

    (* This routine will turn off the cursor.  It may be re-instated by a call
       to CursorOn *)


  PROCEDURE DisplayEntryBar (Length : CARDINAL);

    (* Display a bar, in reverse video, for given length *)


  PROCEDURE At (x, y : INTEGER);

    (* Positions the cursor at row x and column y.  The home position is the
       top left hand corner at (0,0) *)


  PROCEDURE ScrollUp (TopRow, TopCol,
                      BottRow, BottCol,
                      Rows, Attribute : CARDINAL);

    (* Scrolls the given area up Rows rows.  A blank line is inserted at the
       bottom of the area with the given attribute.

       e.g. Attribute `Reverse' will give reverse video spaces for the last
       line *)


  PROCEDURE ScrollDown (TopRow, TopCol,
                        BottRow, BottCol,
                        Rows, Attribute : CARDINAL);

    (* Same as above except moving the text down Rows rows. *)

(*****************************************************************************)

  PROCEDURE GetGCard () : BOOLEAN;

(*****************************************************************************)

  PROCEDURE SetAttribute (Attrib : CARDINAL);

    (* All following text will be printed with the chosen attribute.
       Should colours be used then the number entered must be the
       combined number. *)


  PROCEDURE SetColourAttribute (Fore, Back : CARDINAL);

    (* Sets both foreground and background colours.
       The colours must be entered as the numbers for each of the
       foreground and background - NOT the combined number *)


  PROCEDURE SetForegroundColour (Colour : CARDINAL);

    (* Colour is a cardinal number as listed above.  All text displayed
       after this command will be in the required text *)


  PROCEDURE SetBackgroundColour (Colour : CARDINAL);

    (* Colour is a cardinal number as listed above.  All text displayed
       after this command will be in the required text *)


  PROCEDURE GetColourCode (ForegroundColour,
                           BackgroundColour : CARDINAL;
                           Blink            : BOOLEAN) : CARDINAL;

    (* Input the two colours and a cardinal number will be returned which
       can be used as an attribute for direct memory accessing.

       You only need use this procedure if you have a colour monitor.  Should
       you have a monochrome monitor then use the procedure SetMonoAttrib. *)



  PROCEDURE Setqc (    Pos,
                       Attrib : CARDINAL;
                   VAR Done   : BOOLEAN);

    (* You can set up to 20 pre-defined colour combinations that can be
       accessed through a look-up table.  To set the colours at position Pos
       in the table, you must pass a combined foreground and background colour
       attribute, which can be calculated by the procedure GetColourCode *)


  PROCEDURE qc (Pos : CARDINAL) : CARDINAL;

    (* QuickColour.
       Returns the screen attribute from position Pos of a 20 record look-up
       table. See definition of procedure Setqc. *)


  PROCEDURE CursorRight (Distance : CARDINAL);

    (* Move the cursor distance spaces to the right.  Cursor wraps to the
       beginning of the next line *)


  PROCEDURE CursorLeft (Distance : CARDINAL);

    (*  Move the cursor distance spaces to the left.  Cursor wraps to the
	end of the previous line *)


  PROCEDURE CursorUp (Distance : CARDINAL);

    (* Move cursor up distance spaces *)


  PROCEDURE CursorDown (Distance : CARDINAL);

    (* Move cursor down distance spaces *)


  PROCEDURE CursorHome;

    (* Moves the cursor to the beginning of the line *)


  PROCEDURE CursorEnd;

    (* Moves the cursor to the end of the line *)


  PROCEDURE CursorTop;

    (* Moves the cursor to the top of the page, beginning of the line *)



  PROCEDURE CursorBottom;

    (* Moves the cursor to the bottom of the page and end of the line *)



  PROCEDURE SaveCursorPosition;

    (*  Saves the cursor position.  It is restored with
        `RestoreCursorPosition' *)



  PROCEDURE RestoreCursorPosition;

    (* See above *)

END ScreenHandler.